<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="theme-color" content="#33474d">
	<title>LNMP安装 Discuz！ | 失落的乐章</title>
	<link rel="stylesheet" href="/css/style.css" />
	
      <link rel="alternate" href="/atom.xml" title="失落的乐章" type="application/atom+xml">
    
</head>

<body>

	<header class="header">
		<nav class="header__nav">
			
				<a href="/archives" class="header__link">Archive</a>
			
				<a href="/tags" class="header__link">Tags</a>
			
				<a href="/atom.xml" class="header__link">RSS</a>
			
		</nav>
		<h1 class="header__title"><a href="/">失落的乐章</a></h1>
		<h2 class="header__subtitle">技术面前，永远都是学生。</h2>
	</header>

	<main>
		<article>
	
		<h1>LNMP安装 Discuz！</h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/LNMP/">LNMP</a> <a class="article__tag-link" href="/tags/Nginx/">Nginx</a>
			</span>
		
	</div>

	

	
		<h2 id="1-下载-discuz！"><a href="#1-下载-discuz！" class="headerlink" title="1.下载 discuz！"></a>1.下载 discuz！</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">[root@lnmp ~]<span class="comment"># mkdir /data/www</span></div><div class="line">[root@lnmp ~]<span class="comment"># cd /data/www</span></div><div class="line">[root@lnmp www]<span class="comment"># wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_GBK.zip</span></div><div class="line"></div><div class="line">[root@lnmp www]<span class="comment"># unzip Discuz_X3.2_SC_GBK.zip</span></div><div class="line">[root@lnmp www]<span class="comment"># mv upload/* .</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;删掉其他文件和压缩包</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@lnmp www]<span class="comment"># rm -rf readme/ utility/ upload/ Discuz_X3.2_SC_GBK.zip</span></div></pre></td></tr></table></figure>
<h2 id="2-配置第一个虚拟机"><a href="#2-配置第一个虚拟机" class="headerlink" title="2.配置第一个虚拟机"></a>2.配置第一个虚拟机</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;编辑配置文件 /usr/local/nginx/conf/vhosts/123.conf</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">vim /usr/<span class="built_in">local</span>/nginx/conf/vhosts/123.conf</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;加入内容：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div></pre></td><td class="code"><pre><div class="line">server</div><div class="line">&#123;</div><div class="line">    listen 80;</div><div class="line">    server_name 123.com;</div><div class="line">    index index.html index.htm index.php;</div><div class="line">    root /data/www;</div><div class="line">    location ~ .*admin\.php$ &#123;</div><div class="line">        auth_basic <span class="string">"yanyi auth"</span>;</div><div class="line">        auth_basic_user_file /usr/<span class="built_in">local</span>/nginx/conf/.htpasswd;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    location ~ \.php$ &#123;</div><div class="line">        include fastcgi_params;</div><div class="line">        <span class="comment">#fastcgi_pass unix:/tmp/php-fcgi.sock;</span></div><div class="line">        fastcgi_pass 127.0.0.1:9000;</div><div class="line">        fastcgi_index index.php;</div><div class="line">        fastcgi_param SCRIPT_FILENAME /data/www<span class="variable">$fastcgi_script_name</span>;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;保存退出后，检查配置有没错误：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">[root@lnmp www]<span class="comment"># service nginx configtest </span></div><div class="line">nginx: the configuration file /usr/<span class="built_in">local</span>/nginx/conf/nginx.conf syntax is ok</div><div class="line">nginx: configuration file /usr/<span class="built_in">local</span>/nginx/conf/nginx.conf <span class="built_in">test</span> is successful</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;重新加载 nginx：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">[root@lnmp www]# service nginx reload </div><div class="line">重新载入 Nginx： [确定]</div></pre></td></tr></table></figure>
<h2 id="3-配置-mysql-，给-Discuz！-增加一个账户"><a href="#3-配置-mysql-，给-Discuz！-增加一个账户" class="headerlink" title="3.配置 mysql ，给 Discuz！ 增加一个账户"></a>3.配置 mysql ，给 Discuz！ 增加一个账户</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;给 mysql root 账户设置密码，谈后命令行进入 mysql ，创建新的库，并创建一个新的帐号对该库有所有权限：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">[root@lnmp www]<span class="comment"># /usr/local/mysql/bin/mysql -uroot</span></div><div class="line"></div><div class="line">mysql&gt; create database discuz;</div><div class="line">Query OK, 1 row affected (0.02 sec)</div><div class="line"> </div><div class="line">mysql&gt; grant all on discuz.* to <span class="string">'yanyi'</span>@<span class="string">'localhost'</span> identified by <span class="string">'123456'</span>;</div><div class="line">Query OK, 0 rows affected (0.00 sec)</div><div class="line"> </div><div class="line">mysql&gt; quit</div><div class="line">Bye</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;这样就创建了一个库 discuz ，然后有创建了一个用户 yanyi ，密码是 123456.</p>
<h2 id="4-安装-Discuz！"><a href="#4-安装-Discuz！" class="headerlink" title="4.安装 Discuz！"></a>4.安装 Discuz！</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;因为 123.com 这个域名是随便定义了一个，所以是不能直接访问的，需要先绑定 hosts ，其中hosts 在windows 和 linux 上都是存在的，可以把一个域名指向到一个 ip 上。windows 下的 hosts 文件路径是在：</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;c:\windows\system32\drivers\etc\hosts 。用记事本打开，然后增加一行，保存：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">192.168.0.98   123.com</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;这里的 192.168.0.98 是虚拟机的 ip 。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;浏览器输入：<a href="http://123.com/install/" target="_blank" rel="external">http://123.com/install/</a> ，打开页面</p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/LNMP%E5%AE%89%E8%A3%85%20Discuz%EF%BC%81/01.png?raw=true" alt=""></figure></p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/LNMP%E5%AE%89%E8%A3%85%20Discuz%EF%BC%81/02.png?raw=true" alt=""></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;更改 /data/ 权限</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@lnmp www]<span class="comment"># chmod 777 -R /data/</span></div></pre></td></tr></table></figure>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/LNMP%E5%AE%89%E8%A3%85%20Discuz%EF%BC%81/03.png?raw=true" alt=""></figure></p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/LNMP%E5%AE%89%E8%A3%85%20Discuz%EF%BC%81/04.png?raw=true" alt=""></figure></p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/LNMP%E5%AE%89%E8%A3%85%20Discuz%EF%BC%81/05.png?raw=true" alt=""></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;这一步，数据库名，就是第三步创建的新数据库。数据库用户名和密码也是第三步创建的用户和密码。管理员密码一定要记得。点下一步后，就会看到安装数据库的过程，然后到 “discuz 应用中心”的页面，直接点右下角“点此访问”，就安装成功discuz 论坛了。</p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/LNMP%E5%AE%89%E8%A3%85%20Discuz%EF%BC%81/06.png?raw=true" alt=""></figure></p>

	

	
		<span class="different-posts"><a href="/2017/10/12/Nginx/13. LNMP安装 Discuz！/" onclick="window.history.go(-1); return false;">⬅️ Go back </a></span>

	

</article>

	</main>

	<footer class="footer">
	<div class="footer-content">
		
	      <div class="footer__element">
	<p>Hi there, <br />welcome to my Blog glad you found it. Have a look around, will you?</p>
</div>

	    
	      <div class="footer__element">
	<h5>Check out</h5>
	<ul class="footer-links">
		<li class="footer-links__link"><a href="/archives">Archive</a></li>
		
		  <li class="footer-links__link"><a href="/atom.xml">RSS</a></li>
	    
		<li class="footer-links__link"><a href="/about">about page</a></li>
		<li class="footer-links__link"><a href="/tags">Tags</a></li>
		<li class="footer-links__link"><a href="/categories">Categories</a></li>
	</ul>
</div>

	    

		<div class="footer-credit">
			<span>© 2017 失落的乐章 | Powered by <a href="https://hexo.io/">Hexo</a> | Theme <a href="https://github.com/HoverBaum/meilidu-hexo">MeiliDu</a></span>
		</div>

	</div>


</footer>



</body>

</html>
